<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>Project Information Management</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>beshs/css/content.css" />
	<script type="text/javascript" src="<%=basePath%>resources/jquery/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>resources/datepicker/datepicker.js"></script>
	<!-- 页面特效 -->
	<jsp:include page="/beshs/res-refer/page-effect-reference.jsp" />
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- 表单校验 -->
	<jsp:include page="/resources/resource-refer/component-validform-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
  </head>
  <script type="text/javascript">
  	/* 暂弃不用 */
  	function projManagerVerify() {
  		var projManagerSelect = $("select[name='project.shareAreaManager']").val();
    	var projManagerHandler = $("input[name='project.shareAreaManager']").val();
    	if(projManagerSelect=="" && (projManagerHandler=="" || $.trim(projManagerHandler)=="")) {
    		$("select[name='project.shareAreaManager']").parent("td").find("span").empty().append("<img src='"+path+"beshs/images/wrong.gif' />");
    		return false;
    	} else {
    		$("select[name='project.shareAreaManager']").parent("td").find("span").empty().append("<img src='"+path+"beshs/images/right.gif' />");
        	return true;
    	}
  	}
  	
  	function submitForm() {
  		var projectUID = "<s:property value='projectUID' />";
  		//表单信息
  		var projectID = $("input[name='projectID']").val(); //项目编号
  		var projectName = $("input[name='projectName']").val(); //项目名称
  		var provinceCityID = $("select[name='project.provinceCityID']").val();
  		var capitalCityID = $("select[name='project.capitalCityID']").val();
  		//项目管理员
  		var projManagerSelect = $("select[name='project.shareAreaManager']").val();
    	var projManagerHandler = $("input[name='project.shareAreaManager']").val();
    	//项目阶段
  		var projPhrase = $("select[name='project.projPhrase']").val();
  		var ownerName = $("input[name='ownerName']").val();
  		var ownerTel = $("input[name='ownerTel']").val();
  		var agentName = $("input[name='agentName']").val();
  		var agentTel = $("input[name='agentTel']").val();
  		var workDutyName = $("input[name='workDutyName']").val();
  		var workDutyTel = $("input[name='workDutyTel']").val();
  		var techDutyName = $("input[name='techDutyName']").val();
  		var techDutyTel = $("input[name='techDutyTel']").val();
  		var saleDutyName = $("input[name='saleDutyName']").val();
  		var saleDutyTel = $("input[name='saleDutyTel']").val();
  		var serviceDutyName = $("input[name='serviceDutyName']").val();
  		var serviceDutyTel = $("input[name='serviceDutyTel']").val();
  		var projDate = $("input[name='projDate']").val();
  		var remark = $("textarea[name='remark']").val();
  		$.getJSON(path+"beshs/projectActionJson!saveOrUpdateProject.do?date="+new Date(), {
  			"project.id": projectUID,
  			"project.projectID": projectID,
  			"project.projectName": projectName,
  			"project.provinceCityID": provinceCityID,
  			"project.capitalCityID": capitalCityID,
  			"project.shareAreaManager": projManagerSelect,
  			"projManagerHandler": projManagerHandler,
  			"project.projPhrase": projPhrase,
  			"project.ownerName": ownerName,
  			"project.ownerTel": ownerTel,
  			"project.agentName": agentName,
  			"project.agentTel": agentTel,
  			"project.workDutyName": workDutyName,
  			"project.workDutyTel": workDutyTel,
  			"project.techDutyName": techDutyName,
  			"project.saleDutyName": saleDutyName,
  			"project.serviceDutyName": serviceDutyName,
  			"project.techDutyTel": techDutyTel,
  			"project.saleDutyTel": saleDutyTel,
  			"project.serviceDutyTel": serviceDutyTel,
  			"project.projDate": projDate,
  			"project.remark": remark
  		}, function(data){
  			if(data.success) {
  				Dialog.alert("Successful Operation！", function() {
  					var index = parent.layer.getFrameIndex(window.name)
					parent.window.frames["c_content_content"].location = path + "beshs/projectAction!queryProjectPage.do?date"+new Date();
  					parent.layer.close(index);
  				});
  			} else {
  				Dialog.alert(data.msg);
  			}
  		});
  	}
  	
  	$(function(){
  		$("form[name='projectForm']").Validform({
			btnSubmit: "input[name='submit']",
			btnReset: "input[name='reset']",
			ignoreHidden: true, //对hidden的表单元素将不做验证
			tiptype: function(msg, o, cssctl){
				//msg：提示信息;
				//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
				//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
				if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
					var objtip=o.obj.siblings(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				} else {
					var objtip=o.obj.find("#msgdemo");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
			},
			postonce: true, //开启二次提交防御，在数据成功提交后，表单将不能再继续提交
			showAllError: true, //提交表单时所有错误提示信息都会显示
			beforeSubmit: function(curform) { //在验证成功后，表单提交前执行的函数，curform参数是当前表单对象
				submitForm();
				return true; //这里明确return false的话表单将不会提交
			}
		});
  		
  		$("a[name='switchLink']").click(function() {
  			if($("a[name='switchLink']").text()=="Other"){
  	        	$("select[name='project.shareAreaManager']").hide("fast");
  	        	//清空选择的项目管理员
  	        	$("select[name='project.shareAreaManager']").val("");
  	      		$("input[name='project.shareAreaManager']").show("fast");
  	      		$("a[name='switchLink']").text("Select");
  	        } else {
  	        	$("select[name='project.shareAreaManager']").show("fast");
  	        	$("input[name='project.shareAreaManager']").hide("fast");
  	        	//清空人工填写的项目管理员
  	        	$("input[name='project.shareAreaManager']").val("");
  	        	$("a[name='switchLink']").text("Other");
  	        }
  		})
  	});
  </script>
  <body>
    <div class="content_all">
  		<!--导航条-->
  		<div class="insertinfo_table" >
      		<form action="#" name="projectForm"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        		<tr>
          			<th>Project No.：</th>
          			<td>
          				<input name="projectID" type="text" class="s_input" value="<s:property value='project.projectID' />" 
          					ajaxurl="<%=basePath%>beshs/formAsyncValidateActionJson!validProjectIDUnique.do?entityUuid=<s:property value='project.id' />"
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,25}$/" sucmsg="Project No. Verification Passed！" nullmsg="Please enter Project No.！" errormsg="Project No.only can be composed of letters, numbers and dashes within 1~25 characters！" />
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Project No.only can be composed of letters, numbers and dashes within 1~25 characters！</div></td>
            		<th>Project Name：</th>
          			<td><input name="projectName" type="text" class="s_input" value="<s:property value='project.projectName' />" 
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,45}$/" sucmsg="Project Name Verification Passed！" nullmsg="Please enter Project Name！" errormsg="Project Name only can be composed of letters,numbers and dashes within 1~45 characters！"/>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Project Name only can be composed of letters,numbers and dashes within 1~45 characters！</div></td>
        		</tr>
        		<tr>
          			<th>City：</th>
          			<td colspan="3">
          				<script type="text/javascript">
	          				function reloadChildCitys(provinceCityID, capitalCityID) {
	          					$("select[name='project.capitalCityID']").children("option").slice(1).remove();
		        				if(provinceCityID!=null && provinceCityID!="") {
		        					$.getJSON(path+"beshs/cityActionJson!queryChildCitysByParentUID.do?date="+new Date(), {
		        						parentID: provinceCityID
		        					}, function(data) {
		        						for(var index=0; index<data.length; index++) {
		        							if(capitalCityID!=null && capitalCityID!="" && capitalCityID==data[index].id) {
		        								$("select[name='project.capitalCityID']").append("<option value='"+data[index].id+"' selected='selected'>"+data[index].cityName+"</option>");
		        							} else {
		        								$("select[name='project.capitalCityID']").append("<option value='"+data[index].id+"'>"+data[index].cityName+"</option>");
		        							}
		        						}
		        					});
		        				} 
	          				}
	          				
	          				$(function(){
			        			$("select[name='project.provinceCityID']").change(function(){
			        				var provinceCityID = $(this).val();
			        				var capitalCityID = $("select[name='project.capitalCityID']").val();
			        				reloadChildCitys(provinceCityID, capitalCityID);
			        			});
			        		});
          				</script>
          				<s:select name="project.provinceCityID" list="provinceCityList" listKey="id" listValue="cityName" headerKey="" headerValue="Please Select" cssClass="s_sel"
          					datatype="*" nullmsg="Please Select City！" errormsg="Please Select City！" ></s:select>
			        	<s:select name="project.capitalCityID" list="capitalCityList" listKey="id" listValue="cityName" headerKey="" headerValue="Please Select" cssClass="s_sel"
			        		datatype="*" nullmsg="Please Select City！" errormsg="Please Select City！" ></s:select>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>Project Manager：</th>
          			<td>
          			   <s:select name="project.shareAreaManager" list="shareAreaManagerList" listKey="id" listValue="userID" headerKey="" headerValue="Please Select" cssClass="s_sel"
          			   		datatype="*" nullmsg="Please Select Project Manager！" errormsg="Please Select Project Manager！"></s:select>
          				<input type="text" style="display:none;" name="project.shareAreaManager" class="s_input"
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,25}$/" sucmsg="Project Manager Verification Passed！" nullmsg="Please enter Project Manager!" errormsg="Project Manager only can be composed of letters,numbers and dashes within 1~25 characters！"/>
          				&nbsp;<span style="color:#FF0000;">*</span>&nbsp;<a href="javascript:void(0)" name="switchLink">Other</a>
          				<div class="Validform_checktip"></div></td>
          			<th>Project Stage：</th>
          			<td>
          				<s:select name="project.projPhrase" list="#{'1':'Scheme', '2':'Construction', '3':'Service'}" headerKey="" headerValue="Please Select" cssClass="s_sel" 
          					datatype="*" nullmsg="Please Select Project Stage！" errormsg="Please Select Project Stage！" ></s:select>
          				&nbsp;<span style="color:#FF0000;">*</span>
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
        			<th>Party A's Contact Person：</th>
          			<td><input name="ownerName" type="text" class="s_input" value="<s:property value='project.ownerName' />" 
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,20}$/" ignore="ignore" errormsg="Party A's Contact Person only can be composed of letters,numbers and dashes within 1~20 characters！" />
          				<div class="Validform_checktip"></div></td>
        			<th>Contact Method of Party A's Contact Person：</th>
          			<td><input name="ownerTel" type="text" class="s_input" value="<s:property value='project.ownerTel' />" 
          					datatype="/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/" ignore="ignore" errormsg="Please enter telphone number in correct format！" />
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
        			<th>Agency Contact Person：</th>
          			<td><input name="agentName" type="text" class="s_input" value="<s:property value='project.agentName' />" 
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,20}$/" ignore="ignore" errormsg="Agency Contact Person only can be composed of letters,numbers and dashes within 1~20 characters!"/>
          				<div class="Validform_checktip"></div></td>
        			<th>Contact Method of Agency Contact Person：</th>
          			<td><input name="agentTel" type="text" class="s_input" value="<s:property value='project.agentTel' />" 
          					datatype="/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/" ignore="ignore" errormsg="Please enter telphone number in correct format！" />
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
        			<th>Construction Director：</th>
          			<td><input name="workDutyName" type="text" class="s_input" value="<s:property value='project.workDutyName' />" 
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,20}$/" ignore="ignore" errormsg="Construction Director only can be composed of letters,numbers and dashes within 1~20 characters！"/>
          				<div class="Validform_checktip"></div></td>
          			<th>Contact Method of Construction Director：</th>
          			<td><input name="workDutyTel" type="text" class="s_input" value="<s:property value='project.workDutyTel' />" 
          					datatype="/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/" ignore="ignore" errormsg="Please enter telphone number in correct format!" />
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
        			<th>Technical Director：</th>
          			<td><input name="techDutyName" type="text" class="s_input" value="<s:property value='project.techDutyName' />" 
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,20}$/" ignore="ignore" errormsg="Technical Director only can be composed of letters,numbers and dashes within 1~20 characters！" />
          				<div class="Validform_checktip"></div></td>
        			<th>Contact Method of Technical Director：</th>
          			<td><input name="techDutyTel" type="text" class="s_input" value="<s:property value='project.techDutyTel' />" 
          					datatype="/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/" ignore="ignore" errormsg="Please enter telphone number in correct format！" />
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
        			<th>Sales Director：</th>
          			<td><input name="saleDutyName" type="text" class="s_input" value="<s:property value='project.saleDutyName' />" 
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,20}$/" ignore="ignore" errormsg="Sales Director only can be composed of letters,numbers and dashes within 1~20 characters！" />
          				<div class="Validform_checktip"></div></td>
        		    <th>Contact Method of Sales Director：</th>
          			<td><input name="saleDutyTel" type="text" class="s_input" value="<s:property value='project.saleDutyTel' />" 
          					datatype="/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/" ignore="ignore" errormsg="Please enter telphone number in correct format！" />
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
        			<th>Service Director：</th>
          			<td><input name="serviceDutyName" type="text" class="s_input" value="<s:property value='project.serviceDutyName' />" 
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,20}$/" ignore="ignore" errormsg="Service Director only can be composed of letters,numbers and dashes within 1~20 characters！" />
          				<div class="Validform_checktip"></div></td>
          			<th>Contact Method of Service Director：</th>
          			<td><input name="serviceDutyTel" type="text" class="s_input" value="<s:property value='project.serviceDutyTel' />" 
          					datatype="/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/" ignore="ignore" errormsg="Please enter telphone number in correct format！" />
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>Project Date：</th>
          			<td>
          			<input id="project_projDate" name="projDate" class="Wdate" value="<s:date name='project.projDate' format='yyyy-MM-dd' nice='false' />" errormsg="Please enter date and time in correct format such as-- 2014-07-19！" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})" />
          			
<%--           				<input name="projDate" id="project_projDate" type="text" class="s_input" value="<s:date name='project.projDate' format='yyyy-MM-dd' nice='false' />" onclick="selectDate(this,'yyyy-MM-dd')"  --%>
<!--           					datatype="/^(\d{4})-(\d{1,2})-(\d{1,2})$/" ignore="ignore" errormsg="Please enter date and time in correct format such as-- 2014-07-19！" readonly/> -->
<%--           				<img src="<%=basePath%>resources/datepicker/calendar.jpg" onclick="txtSelectDate('project_projDate','yyyy-MM-dd')"/> --%>
          				<div class="Validform_checktip"></div></td>
          			<th></th>
          			<td></td>
        		</tr>
        		<tr>
        			<th>Remark：</th>
          			<td colspan="3">
          				<textarea name="remark" cols="45" rows="3" 
          					datatype="*1-200" ignore="ignore" errormsg="Invalid input!  please input valid content ,no more than 200pcs character">
          					<s:property value='project.remark' /></textarea>
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<td style="border:none;" colspan="4" align="center">
          				<input name="submit" type="button" value="Submit" class="s_btn" />
            			<input name="reset" type="reset" value="Reset" class="s_btn"/></td>
        		</tr>
      		</table></form>
  		</div>
	</div>
	<div class="clear"></div>
  </body>
</html>
